home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************************/
- /* */
- /* main.c - Serial NB (what a stupid name) asynchronous driver. */
- /* */
- /* Richard W. Mincher. February 19, 1990. */
- /* */
- /* Copyright © 1990, Apple Computer, Inc. All rights reserved. */
- /* */
- /* */
- /* DISCLAIMER: Don't blame me for the serial driver interface. */
- /* */
- /********************************************************************************/
-
- #define MAIN
-
- #include "AROSE.h"
- #include "os.h"
- #include "managers.h"
-
- #include "ARDriver.h"
- #include "ARTask.h"
-
- long GetA5() extern 0x200d;
- main()
- {
- tid_type temp;
- long a5;
- unsigned char *c;
-
- a5 = GetA5();
- G->tbeCount = G->srcCount = G->escCount = G->rcaCount = 0;
- #ifdef DEBUG
- printf("SNBTask starting. port = %d; a5 = %x\n", PORT, a5);
- #endif DEBUG
-
- c = GetStParms();
- BlockMove( &c[1], (char *)0x700, c[0] );
- InitTask();
- while(open)
- {
- if (msg = Receive( 0, 0, 0, 20 ))
- {
- #ifdef DEBUG
- printf("msg: mCode=%x; mFrom=%x; mDataPtr=%x; mDataSize=%x; mStatus=%x\n",
- msg->mCode, msg->mFrom, msg->mDataPtr, msg->mDataSize, msg->mStatus );
- #endif DEBUG
- reply = 1;
- switch( msg->mCode )
- {
- case SNBOpen:
- OpenCall();
- break;
- case SNBClose:
- CloseCall();
- break;
- case SNBRead:
- reply = 0;
- ReadCall();
- break;
- case SNBWrite:
- reply = 0;
- WriteCall();
- break;
- case SNBControl:
- ControlCall();
- break;
- case SNBStatus:
- StatusCall();
- break;
- case 1000: /* Write interrupt */
- reply = 0;
- G->txSignal = msg;
- TickleWrite();
- break;
- case 2000: /* Read interrupt */
- reply = 0;
- G->rxSignal = msg;
- TickleRead();
- break;
- default:
- #ifdef DEBUG
- printf("default: mCode=%x; mFrom=%x; mTo=%x; mStatus=%x\n",
- msg->mCode, msg->mFrom, msg->mTo, msg->mStatus );
- #endif DEBUG
- msg->mCode |= 0x8000;
- break;
- }
- if (reply)
- {
- temp = msg->mFrom;
- msg->mFrom = msg->mTo;
- msg->mTo = temp;
- msg->mCode |= 1;
- Send( msg );
- #ifdef DEBUG
- printf("Reply sent.\n");
- #endif DEBUG
- }
- }
- else
- {
- TickleRead();
- TickleWrite();
- }
- }
- #ifdef DEBUG
- printf("ARTask exiting.\n");
- printf("tbeCount = %d, rcaCount=%d, escCount=%d, srcCount=%d\n",
- G->tbeCount, G->rcaCount, G->escCount, G->srcCount );
- #endif DEBUG
- }
-